package com.mszlu.blog.controller;

import com.mszlu.blog.dao.pojo.Tag;
import com.mszlu.blog.service.TagService;
import com.mszlu.blog.vo.Result;
import com.mszlu.blog.vo.params.TagPageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Package: com.mszlu.blog.controller
 * @ClassName: TagController
 * @Author: 陈威
 * @CreateTime: 2021/8/29 13:33
 * @Description:
 */
@RestController
@RequestMapping("/tags")
public class TagController {
    @Autowired
    private TagService tagService;

    //最热标签文章列表
    @GetMapping("/hot")
    public Result listHotTags() {
        int limit = 6;
        Result hot = tagService.hot(limit);
        return hot;
    }

    @GetMapping("detail")
    public Result findAllDetail(){
        return tagService.findAll();
    }
    @GetMapping()
    public Result findAll(){
        return tagService.findAll();
    }
    //标签文章列表
    @GetMapping("detail/{id}")
    public Result findDetailById(@PathVariable("id") Long id){
        return tagService.findDetailById(id);
    }

    //全部标签
    @PostMapping("tagAll")
    public Result gettagAll(@RequestBody TagPageParam params){
        return tagService.getTagAll(params);
    }
    //根据id删除标签
    @PostMapping("deletetagById/{id}")
    public Result deletetagById(@PathVariable("id")Long id){
        return tagService.deleteTagById(id);
    }
    //修改标签
    @PostMapping("updateTag")
    public Result UpdatetagById(@RequestBody Tag tag){
        return tagService.UpdateTagById(tag);
    }
    //添加标签
    @PostMapping("addTag")
    public Result addtag(@RequestBody Tag tag){
        return tagService.addTag(tag);
    }
}